/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   any later version.                                                    *
 ***************************************************************************/

#include "asuro.h"
int value=80;
unsigned int lData[2];
float r = 0.4;

void setContrast(){
        int hell;
        int dunkel;
        StatusLED(YELLOW);
        Msleep(5000);
        StatusLED(GREEN);
        LineData(lData);
        hell = (int) lData[LEFT];
        Msleep(1000);
        StatusLED(YELLOW);
        Msleep(5000);
        StatusLED(GREEN);
        dunkel = lData[LEFT];
        Msleep(1000);
        value=(int)((hell+dunkel)/2);

}


int main(void) {
        Init();
        FrontLED(ON);
        setContrast();
        while (1) {
                LineData(lData);
                int leftLux = (int) lData[LEFT];
                if(leftLux>value){
                        StatusLED(RED);
                        SetMotorPower(100,(int)100*r);
                }else{
                        StatusLED(GREEN);
                        SetMotorPower((int)100*r,100);
                }
        }
        while (1);
        return 0;
}

